<? if (stack('id')) {
	
	if (!function_exists(cpnAlbumData)) {
		function cpnAlbumData($params) {
			
			$s = component_settings($params['name']);
			$res = array();

			foreach($params['params']['tags'] as $tag) {

				switch($tag) {
					case 'gallery':
						
					
						$t = datafetch_array('meta', D_MB_META, $params['params']['gparam'], context('lang'));
						$res[$tag]['title'] = $t['title'];
					
						$res[$tag]['data'] = datafetch_array('gallery2', $s['path']);	// load existing images list
						
						if ($s['fancybox'])	// attach the fancybox css
							$META['style'][] = 'jquery.fancybox';
					
						break;
						
					case 'gallery-list':
					
						$_id_component	= $params['id'];			//	list id value
						$_id_data		= D_MB_DATA;			//	meta id value
						$_id_meta		= D_MB_META;			//	meta id value
						
						$_crit = "id_data=$_id_data AND id_parent=$_id_component AND ".dbAndL('attr', AA_VISIBLE);
					
						$res[$tag]['data'] = array_mark_bounds( datafetch_array('db_list', array('table' => tb('data'), 'where' => "$_crit",	'order' => 'id_index', 'index' => 'id' )));
					
						foreach($res[$tag]['data'] as $k => $v) {
							$res[$tag]['data'][$k] = array_merge($v, datafetch_array('meta', $_id_meta, $k, $CONTEXT['lang']));	// !!! need optimization
							$res[$tag]['data'][$k]['image'] = checkImage($s['path'], $k);
						}
					
						break;
						
				}
				
				
			}
			return $res;
		}
	}
	
	
	return unstack(cpnAlbumData(stack()));
}